package com.snake.springboot.authority.web.controller;

import com.snake.springboot.authority.api.model.AuthSystemModel;
import com.snake.springboot.authority.api.service.AuthSystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.snake.common.result.ResponseResult;
import org.snake.common.result.ResponseResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 类 {@code AuthSystemController}  <br> .
 * <p>权限管理-系统信息
 * 创建时间：2024/5/30 17:19
 *
 * @author huang.yj
 * @see
 */

@Api(tags = "权限管理-系统信息")
@RestController
@RequestMapping("/auth/system")
public class AuthSystemController {

    private AuthSystemService authSystemService;

    @Autowired
    public AuthSystemController(AuthSystemService authSystemService) {
        this.authSystemService = authSystemService;
    }

    @ApiOperation("添加系统信息")
    @PostMapping("/add")
    public ResponseResult<AuthSystemModel> addAuthSystem(
            @ApiParam(name = "权限系统信息入参", value = "传入json格式", required = true)
            @RequestBody AuthSystemModel model){
        AuthSystemModel result = authSystemService.addSystem(model);
        return ResponseResultFactory.ucc("添加成功！", result);
    }

    @ApiOperation("修改系统信息")
    @PostMapping("/modify")
    public ResponseResult<AuthSystemModel> modifyAuthSystem(
            @ApiParam(name = "权限系统信息入参", value = "传入json格式", required = true)
            @RequestBody AuthSystemModel model){
        authSystemService.modifySystem(model);
        return ResponseResultFactory.ucc("修改成功！");
    }

    @ApiOperation("删除系统信息")
    @GetMapping("/remove/{systemid}")
    public ResponseResult<Object> removeAuthSystem(
            @ApiParam(name = "权限系统信息ID", value = "传入json格式", required = true)
            @PathVariable("systemid") String systemId) {
        authSystemService.removeSystem(systemId);
        return ResponseResultFactory.ucc("删除成功！");
    }

    @ApiOperation("查询系统信息详情")
    @GetMapping("/query/{systemid}")
    public ResponseResult<AuthSystemModel> querySingleAuthSystem(
            @ApiParam(name = "权限系统信息ID", value = "传入json格式", required = true)
            @PathVariable("systemid") String systemId) {
        AuthSystemModel result = authSystemService.querySingleSystem(systemId);
        return ResponseResultFactory.ucc("删除成功！", result);
    }

    @ApiOperation("查询系统信息列表")
    @PostMapping("/list")
    public ResponseResult<List<AuthSystemModel>> queryAuthSystemList(
            @ApiParam(name = "查询参数", value = "传入json格式", required = true)
            @RequestBody AuthSystemModel params){
        List<AuthSystemModel> result = authSystemService.querySystemList(params);
        return ResponseResultFactory.ucc("查询成功！", result);
    }

}
